home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Sunday Times: The Month 2004 October
/
The Sunday Times - The Month 2004-10.iso
/
pc
/
assets
/
bespoke
/
kids
/
power.swf
/
scripts
/
frame_5
/
DoAction.as
Wrap
Text File
|
2004-09-02
|
5KB
|
232 lines
function levelObj(shape, rSpeed, zSpeed, levelTime, levelBonus)
{
this.shape = shape;
this.rSpeed = rSpeed;
this.zSpeed = zSpeed;
this.levelTime = levelTime;
this.levelBonus = levelBonus;
}
function startLevel(num)
{
levelScore = 0;
pcount = 0;
popList = new Array();
popsLeft = 0;
countdownTimer.setTimer(levels[currLevel].levelTime);
txtLevelTotal = levels.length;
txtLevelCurrent = currLevel + 1;
if(levels[currLevel].shape == 1)
{
fillPopGrid();
}
else if(levels[currLevel].shape == 2)
{
fillPopWave();
}
else if(levels[currLevel].shape == 3)
{
fillPopRings();
}
else if(levels[currLevel].shape == 4)
{
fillPopSpiro();
}
pcount = 0;
gotoAndPlay(9);
}
function resetGame()
{
currLevel = 0;
gameScore = 0;
gameScoreTxt = 0;
}
function fillPopGrid()
{
var gridWidth = 10;
var gridHeight = 10;
var gridSpacing = 23;
var popSize = 20;
var xbase = (- (gridWidth - 1) / 2) * gridSpacing;
var ybase = (- (gridHeight - 1) / 2) * gridSpacing;
i = 0;
while(i < gridWidth)
{
j = 0;
while(j < gridHeight)
{
var xval = xbase + gridSpacing * i;
var yval = ybase + gridSpacing * j;
generatePopper(xval,yval,popSize);
j++;
}
i++;
}
}
function fillPopWave()
{
var gridWidth = 10;
var gridHeight = 10;
var gridSpacing = 21;
var popSize = 20;
var xbase = (- (gridWidth - 1) / 2) * gridSpacing;
var ybase = (- (gridHeight - 1) / 2) * gridSpacing;
var xoffset = 0;
var xradsinc = 0;
var yoffset = 0;
var yradsinc = 0;
i = 0;
while(i < gridWidth)
{
xradsinc = 0;
j = 0;
while(j < gridHeight)
{
xoffset = Math.sin(xradsinc) * 50;
var xval = xbase + gridSpacing * i + xoffset;
var yval = ybase + gridSpacing * j;
generatePopper(xval,yval,popSize);
xradsinc += 0.75;
j++;
}
i++;
}
}
function fillPopRings()
{
var rings = 5;
var baseRadius = 23;
var popSize = 20;
i = 0;
while(i < rings)
{
var radius = baseRadius + baseRadius * i;
var pRing = 10 + 5 * i;
var radSep = 6.283185307179586 / pRing;
j = 0;
while(j < pRing)
{
var xval = Math.sin(j * radSep) * radius;
var yval = Math.cos(j * radSep) * radius;
generatePopper(xval,yval,popSize);
j++;
}
i++;
}
}
function fillPopSpiro()
{
var branches = 8;
var popSize = 20;
i = 0;
while(i < branches)
{
var radius = 18;
var pRing = 9;
var radSep = 2.0734511513692637 / pRing;
var radOffset = i * (6.283185307179586 / branches);
var radiusInc = 15;
j = 0;
while(j < pRing)
{
var xval = Math.sin(radOffset + j * radSep) * radius;
var yval = Math.cos(radOffset + j * radSep) * radius;
generatePopper(xval,yval,popSize);
radius += radiusInc;
j++;
}
i++;
}
}
function generatePopper(x, y, s)
{
pcount++;
popStage.popMaster.duplicateMovieClip("pop" + pcount,pcount + 100);
thisPop = popStage["pop" + pcount];
thisPop.food.gotoAndStop(Math.round(Math.random() * 10) + 1);
thisPop._x = x;
thisPop._y = y;
thisPop._width = thisPop._height = s;
thisPop._visible = false;
popList.push(thisPop);
}
function popMe()
{
this._visible = false;
popsLeft--;
if(popsLeft == 0)
{
finishTime = getTimer();
gotoAndStop(1);
}
}
function getAngToPoint(fromX, fromY, toX, toY)
{
tempXoffset = fromX - toX;
tempYoffset = toY - fromY;
var tempAngToPoint = Math.round(Math.atan2(tempXoffset,tempYoffset) * rads) + 180;
return tempAngToPoint;
}
function atan(mx, my, cx, cy)
{
dx = mx - cx;
dy = my - cy;
at = Math.atan(dy / dx) * 180 / 3.141592653589793;
if(dx >= 0)
{
if(dy >= 0)
{
angle = at;
}
else
{
angle = at + 360;
}
}
if(dx < 0)
{
if(dy > 0)
{
angle = at + 180;
}
else
{
angle = at + 180;
}
}
return angle;
}
stop();
_quality = "medium";
globalScale = 80;
stop();
levelBonus = 250;
timeBonus = 10;
sfx = new Array();
sfx[0] = new Sound();
sfx[0].attachSound("bip");
sfx[0].setVolume(25);
sfx[1] = new Sound();
sfx[1].attachSound("pop2");
sfx[1].setVolume(25);
sfx[2] = new Sound();
sfx[2].attachSound("countdown");
sfx[2].setVolume(25);
levels = new Array();
levels.push(new LevelObj(1,0,0,30,100));
levels.push(new LevelObj(2,0,0,30,150));
levels.push(new LevelObj(3,0,0,28,200));
levels.push(new LevelObj(4,0,0,28,250));
levels.push(new LevelObj(1,1,0,26,300));
levels.push(new LevelObj(2,1,0,26,350));
levels.push(new LevelObj(3,1,0,25,400));
levels.push(new LevelObj(4,1,0,25,450));
levels.push(new LevelObj(1,0,1,24,500));
levels.push(new LevelObj(2,0,1,24,550));
levels.push(new LevelObj(3,0,1,23,600));
levels.push(new LevelObj(4,0,1,23,650));
levels.push(new LevelObj(1,3,3,22,700));
levels.push(new LevelObj(2,3,3,22,750));
levels.push(new LevelObj(3,3,3,20,800));
levels.push(new LevelObj(4,3,3,20,850));
currLevel = 0;